package com.dd.poetry

import com.google.android.material.bottomnavigation.BottomNavigationView
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupActionBarWithNavController
import androidx.navigation.ui.setupWithNavController
import com.alibaba.android.arouter.facade.annotation.Route
import com.dd.common.base.BaseActivity
import com.dd.common.router.MAIN_ACTIVITY
import com.dd.poetry.databinding.ActivityMainBinding

@Route(path = MAIN_ACTIVITY)
class MainActivity : BaseActivity<ActivityMainBinding, MainModel>() {
    private val _binding get() = binding!!
    private val _viewModel get() = model!!
    override fun getViewBinding(): ActivityMainBinding {
        return ActivityMainBinding.inflate(layoutInflater)
    }

    override fun getViewModel(): MainModel {
        return ViewModelProvider(this)[MainModel::class.java]
    }

    override fun initUI() {
        val navView: BottomNavigationView = _binding.navView
        val navController = findNavController(R.id.nav_host_fragment_activity_main)
        val appBarConfiguration = AppBarConfiguration(
            setOf(
                R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications
            )
        )
        setupActionBarWithNavController(navController, appBarConfiguration)
        navView.setupWithNavController(navController)
    }
}